<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="<?php echo base_url("theme/css");?>/reset.css" media="screen" />
<link type="text/css" rel="stylesheet" href="<?php echo base_url("theme/css");?>/template_view.css" media="screen" />
<link type="text/css" rel="stylesheet" href="<?php echo base_url('modules/style_'.$moduleType.'/'.$modl_name);?>.css" />
<script type="text/javascript" src="<?php echo base_url("theme/js");?>/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo base_url("theme/js");?>/main.js"></script>
<script type="text/javascript" src="<?php echo base_url("theme/js/ui");?>/jquery.ui.core.js"></script>
<script type="text/javascript" src="<?php echo base_url("theme/js/ui");?>/jquery.ui.widget.js"></script>
<script type="text/javascript" src="<?php echo base_url("theme/js/ui");?>/jquery.ui.mouse.js"></script>
<script type="text/javascript" src="<?php echo base_url("theme/js/ui");?>/jquery.ui.sortable.js"></script>
<script type="text/javascript" src="<?php echo base_url("theme/js/colorbox");?>/jquery.colorbox.js"></script>
<script type="text/javascript">
jQuery(function(){
		
		jQuery( ".lv1" ).sortable({ connectWith: "ul.lv1" });
		jQuery( "dl.lv2" ).sortable({ connectWith: "dl.lv2" });
		
		jQuery( "dl.lv2 dd" ).sortable({ connectWith: ".iconsBox",cancel: "dl.lv2 dd a" });
		jQuery( ".iconsBox" ).sortable({ connectWith: "dl.lv2 dd" }); //拖动小图标
		
		jQuery( "#customAddok" ).live('click',function(){
					if( !jQuery.trim(jQuery("#customAddName").val())){alert('提示:分类名称不能为空'); return false;}
					if( jQuery.trim(jQuery("#customAddUrl").val()) == 'http://'){alert('提示:链接地址不能为空并以 http:// 开头'); return false;}	
						
					if(jQuery( "input[name='urlType']:radio:checked" ).val() == 1){
						jQuery( ".lv2cus" ).append('<dt class="ui-sortable"><a href="'+jQuery("#customAddUrl").val()+'" target="_blank">'+jQuery("#customAddName").val()+'</a></dt>');
					}else{
						jQuery( ".lv2cus" ).append('<dd class="ui-sortable"><a href="'+jQuery( "#customAddUrl" ).val()+'" target="_blank">'+jQuery( "#customAddName" ).val()+'</a></dd>');
					}
				});
                                
       $("#save_module").click(function(){
		//alert(tt=encodeURIComponent($("#saveToDatabase").html()));
              //  alert(decodeURIComponent(tt));
  
			var tmpname=$("#tmpname").val();
			var tmpath=$("#modlname").val();
			if( !jQuery.trim(jQuery("#tmpname").val())){
						alert('提示:为了方便管理,请先个模块起个名称。'); return false;
						}
			
			$.ajax({
				   type: "POST",
				 url: "../../savetmp",
                                //  url: "http://127.0.0.1/1.php",
				   data: "tmpname="+tmpname+"&tmpath="+tmpath+"&htmlcontent="+encodeURIComponent($("#saveToDatabase").html()),
				   success: function(){
                                     // alert(msg);
					   alert("模块已保存，请到模块管理设置默认模块。");
					   window.parent.location="<?php echo $redirectudl;?>";
				   }
			});
		});         		   
	
	jQuery('#keyboard #toggleTool span').click(function(){
			jQuery(this).addClass('cur').siblings('span').removeClass('cur');
			var _index = jQuery('#keyboard #toggleTool span').index(this);
			jQuery('#keyboard .kbox').eq(_index).css('display','block').siblings('.kbox').css('display','none');
		});

	//旺旺拖动
	jQuery( "ul.wwBox1" ).sortable({ connectWith: "ul.wwBox1" });
	jQuery( "dl.wwBox2" ).sortable({ connectWith: "dl.wwBox2" });
	jQuery( "dl.wwBox2 dd" ).sortable({ connectWith: "dl.wwBox2 dd" });
	jQuery( ".wwBox2cus" ).sortable({ connectWith: "dl.wwBox2 dd" }); //拖动新添加的昵称
	jQuery( "#customAddNickok" ).live('click',function(){
					if( !jQuery.trim(jQuery("#customNick").val())){alert('提示:昵称不能为空'); return false;}
					jQuery( ".wwBox2cus" ).append('<span>'+jQuery("#customNick").val()+':</span>');
				});
	
	
});
	
</script>
<title>聚客_分类导航与旺旺客服</title>
</head>

<?php $_mwidth = explode('_',$modl_name);?>
<body id="<?php echo $moduleType.$_mwidth[0];?>" class="<?php echo $moduleType;?>">

    
		<?php $this->load->view('tmp_'.$moduleType.'/'.$modl_name);  ?>          
    	<!-- <textarea id="saveToDatabaseCode" name="saveToDatabaseCode"></textarea> -->
        
        <div class="btns">
           <p> 模块名称: <input type="text" size="20" id="tmpname" name="tmpname" /></p>
            <input name="modlname" type="hidden"  id ="modlname"  value="<?php echo "{$moduleType}/{$modl_name}"; ?>" />
            <input type="button" value="完成并保存模块" id="save_module" />
        </div>
        
    
</body>
</html>